Skip to content

fix(bin): decode proxy response streams with StringDecoder (#4336) - #4341

Merged
dezren39 merged 1 commit into
mainfrom
queue/6213-4336-stringdecoder
Nov 2, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/6213-4336-stringdecoder

Conversation

@dezren39

@dezren39 dezren39 commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Fixes #4336 — the response-side twin of #3186.

Problem

Across bin/, subprocess stdout line buffers and upstream response accumulators decoded each chunk separately (buffer += chunk.toString('utf-8')), so a multibyte UTF-8 sequence split across chunks became U+FFFD inside JSON string values and was silently forwarded to clients. Verified on main f854b4d: all nine primary sites present, zero StringDecoder in bin/.

Change

  • New shared helper bin/stream-decode.mjs (createStreamDecoder(), wrapping node:string_decoder) — the streaming counterpart of bin/request-body.mjs.
  • Stdout line buffers now decode through a per-stream decoder: agy-proxy _onStdout, claude-code-proxy _onStdout, codex-proxy, commandcode-proxy (both handlers), muse-proxy (warm + cold handlers).
  • design-code-proxy: SSE accumulator decodes through a decoder; the non-streaming body is Buffer-concat and decoded once (the request-body house pattern).
  • Same-pattern lower-impact sites from the issue are also fixed, not declined: per-chunk stderr tails in all six files, agy-proxy models-pull stdout (parseAgyModelsOutput input), muse-proxy --flag scan accumulator.

Tests

  • New bin/stream-decode.test.mjs: split at every byte offset of a JSON line containing 3-byte and 4-byte sequences, one-byte-at-a-time feeding, and a JSON-parse check after a split inside the 3-byte sequence.
  • CI-first verification: existing per-proxy test suites (agy, claude-code, codex, commandcode, muse, design-code) run in CI on this PR; no local suite was run (sandbox/laptop build ban — node --check syntax-verified only).

Enqueued by triage task 6208; worked as queue task 6213.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 2, 2026 11:43
@coderabbitai

coderabbitai Bot commented Nov 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 25 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 27e7bb99-f2f4-4b59-b074-eda5561ccbaf
Commits

Reviewing files that changed from the base of the PR and between f854b4d and 50ba5cf.

Files selected for processing: 8
  • bin/agy-proxy.mjs
  • bin/claude-code-proxy.mjs
  • bin/codex-proxy.mjs
  • bin/commandcode-proxy.mjs
  • bin/design-code-proxy.mjs
  • bin/muse-proxy.mjs
  • bin/stream-decode.mjs
  • bin/stream-decode.test.mjs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T12:59:09.219632Z 50ba5cf Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39

dezren39 commented Nov 2, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 50ba5cf2bf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant